<?php
$sid=session_id();
session_start();
require_once 'config.inc';
require_once 'lib/common.inc.php';
$Password=new Password();
if (isset ($_POST["loginUsername"])){

  $username=$_POST["loginUsername"];
  $password=$_POST["loginPassword"];
  
  $mysql=new mySQL(array( "db_user" => $username,
                          "db_pass" => $Password->encrypt($password),
                          "db_host" => DB_HOST));
  if (!$mysql->dbconnect()){
    echo encodeResponse(false,"Can't connect to mySQL Server. Username or password incorect");
  }
  else{
    
    $_SESSION["token"]=$sid;
    $_SESSION["dbuser"] = $username;
    $_SESSION["dbpass"] = $Password->encrypt($password);  
    $_SESSION["selDB"] = "information_schema";  
    
    $mysql->selected_db("information_schema");    
  }
}
else{
  header("Location: login.php");
}
?>
